/**
 * Copyright 2014 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.dao.report;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import org.springframework.beans.factory.annotation.Autowired;

import com.viettel.core.entities.report.ReportUserTextDaily;
import com.viettel.core.entities.report.vo.ReportUserFilter;
import com.viettel.core.entities.report.vo.ReportUserVO;
import com.viettel.core.exceptions.DataAccessException;
import com.viettel.core.repo.IRepository;

/**
 * Mo ta muc dich cua lop (interface)
 * 
 * @author: TOANTM1
 * @version:
 * @since: 17/07/2014 - 10:49:55
 */
public class ReportUserDAOImpl implements ReportUserDAO {
    
	private IRepository repo; 
	
 	public void setRepo(IRepository repo) {
		this.repo = repo;
	}

	/**
	 * @author TOANTM1 17/07/2014 - 10:49:55 For:
	 * @description:
	 */
	@Override
	public ReportUserTextDaily getReportUserTextDailyById(Long id)
			throws DataAccessException {
		return repo.getEntityById(ReportUserTextDaily.class, id);
	}

	/**
	 * @author TOANTM1 17/07/2014 - 10:49:55 For:
	 * @description:
	 */
	@Override
	public ReportUserTextDaily createReportUserTextDaily(
			ReportUserTextDaily reportusertextdaily) throws DataAccessException {
		if (reportusertextdaily == null) {
			throw new IllegalArgumentException("reportusertextdaily");
		}
		repo.create(reportusertextdaily);
		return repo.getEntityById(ReportUserTextDaily.class,
				reportusertextdaily.getId());
	}

	/**
	 * @author TOANTM1 17/07/2014 - 10:49:55 For:
	 * @description:
	 */
	@Override
	public void updateReportUserTextDaily(
			ReportUserTextDaily reportusertextdaily) throws DataAccessException {
		if (reportusertextdaily == null) {
			throw new IllegalArgumentException("reportusertextdaily");
		}
		repo.update(reportusertextdaily);
	}

	/**
	 * @author TOANTM1 17/07/2014 - 10:49:55 For:
	 * @description:
	 */
	@Override
	public void deleteReportUserTextDaily(
			ReportUserTextDaily reportusertextdaily) throws DataAccessException {
		if (reportusertextdaily == null) {
			throw new IllegalArgumentException("reportusertextdaily");
		}
		repo.delete(reportusertextdaily);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserTextDaily(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserTextDaily(
			ReportUserFilter fillter) throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();

		selectSql.append("SELECT SUM(total_user) totalUser, \n");
		selectSql.append("  group_name groupName, \n");
		selectSql.append("  service_code serviceCode \n");
		fromQuery.append("FROM report_user_text_daily a \n");
		fromQuery
				.append("WHERE TRUNC(report_date,'DD') >= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery
				.append("AND TRUNC(report_date,'DD')   <= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery.append("AND group_id is not null \n");
		selectParams.add(fillter.getFromDate());
		selectParams.add(fillter.getToDate());
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		selectSql.append(fromQuery);
		selectSql.append("GROUP BY group_name, \n");
		selectSql.append("  service_code, \n");
		selectSql.append("  source_name \n");
		selectSql.append("ORDER BY group_name, \n");
		selectSql.append("  service_code ASC");

		countSql.append("SELECT COUNT(*) AS COUNT ").append("from (select 1 ").append(fromQuery).append(" GROUP BY group_name, service_code) ");

		String[] fieldNames = new String[] { "totalUser", "groupName", "serviceCode" };

		Type[] fieldTypes = new Type[] { StandardBasicTypes.LONG, StandardBasicTypes.STRING, StandardBasicTypes.STRING};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), selectParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), selectParams,
					selectParams, fillter.getPaging());
		}
		return list;
	}

	/** (non-Javadoc)
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserTextMonthly(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserTextMonthly(
			ReportUserFilter fillter) throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();

		selectSql.append("SELECT SUM(total_user) totalUser, \n");
		selectSql.append("  group_name groupName, \n");
		selectSql.append("  service_code serviceCode \n");
		fromQuery.append("FROM report_user_text_monthly a \n");
		fromQuery.append("WHERE report_month=TO_NUMBER(TO_CHAR(sysdate,'yyyyMM')) \n");
		fromQuery.append("AND group_id is not null \n");
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		selectSql.append(fromQuery);
		selectSql.append("GROUP BY group_name, \n");
		selectSql.append("  service_code, \n");
		selectSql.append("  source_name \n");
		selectSql.append("ORDER BY group_name, \n");
		selectSql.append("  service_code ASC");

		countSql.append("SELECT COUNT(*) AS COUNT ").append("from (select 1 ").append(fromQuery).append(" GROUP BY group_name, service_code) ");
		

		String[] fieldNames = new String[] { "totalUser", "groupName", "serviceCode" };

		Type[] fieldTypes = new Type[] { StandardBasicTypes.LONG, StandardBasicTypes.STRING, StandardBasicTypes.STRING};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), selectParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), selectParams,
					selectParams, fillter.getPaging());
		}
		return list;
	}

	/** (non-Javadoc)
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserSubDaily(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserSubDaily(ReportUserFilter fillter)
			throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();
		
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  SUM(new_user) newUser, \n");
		selectSql.append("  SUM(out_user) outUser, \n");
		selectSql.append("  SUM(out_user_other) outUserOther \n");
		
		fromQuery.append("FROM report_user_sub_daily a \n");
		fromQuery.append("WHERE TRUNC(a.report_date,'DD') >= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery.append("AND TRUNC(a.report_date,'DD')   <= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery.append("AND group_id is not null \n");
		selectParams.add(fillter.getFromDate());
		selectParams.add(fillter.getToDate());
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		selectSql.append(fromQuery);
		selectSql.append("GROUP BY GROUP_NAME, \n");
		selectSql.append("  service_code \n");
		selectSql.append("ORDER BY lower(GROUP_NAME), \n");
		selectSql.append("  lower(service_code)");

		countSql.append("SELECT COUNT(*) AS COUNT ").append("from (select 1 ").append(fromQuery).append(" GROUP BY group_name, service_code) ");
		

		String[] fieldNames = new String[] { 
				"groupName", "serviceCode", "totalUser",
				"newUser", "outUser", "outUserOther" 
				
		};

		Type[] fieldTypes = new Type[] { 
				StandardBasicTypes.STRING, StandardBasicTypes.STRING, StandardBasicTypes.LONG,
				StandardBasicTypes.LONG, StandardBasicTypes.LONG, StandardBasicTypes.LONG
				
		};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), selectParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), selectParams,
					selectParams, fillter.getPaging());
		}
		return list;
	}

	/** (non-Javadoc)
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserSubMonthly(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserSubMonthly(ReportUserFilter fillter)
			throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();
		
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  SUM(new_user) newUser, \n");
		selectSql.append("  SUM(out_user) outUser, \n");
		selectSql.append("  SUM(out_user_other) outUserOther \n");
		
		fromQuery.append("FROM report_user_sub_monthly a \n");
		fromQuery.append("WHERE report_month=TO_NUMBER(TO_CHAR(sysdate,'yyyyMM')) \n");
		fromQuery.append("AND group_id is not null \n");
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		selectSql.append(fromQuery);
		selectSql.append("GROUP BY GROUP_NAME, \n");
		selectSql.append("  service_code \n");
		selectSql.append("ORDER BY lower(GROUP_NAME), \n");
		selectSql.append("  lower(service_code)");

		countSql.append("SELECT COUNT(*) AS COUNT ").append("from (select 1 ").append(fromQuery).append(" GROUP BY group_name, service_code) ");

		String[] fieldNames = new String[] { 
				"groupName", "serviceCode", "totalUser",
				"newUser", "outUser", "outUserOther" 
				
		};

		Type[] fieldTypes = new Type[] { 
				StandardBasicTypes.STRING, StandardBasicTypes.STRING, StandardBasicTypes.LONG,
				StandardBasicTypes.LONG, StandardBasicTypes.LONG, StandardBasicTypes.LONG
				
		};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), selectParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), selectParams,
					selectParams, fillter.getPaging());
		}
		return list;
	}

	/** (non-Javadoc)
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserAllDaily(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserAllDaily(ReportUserFilter fillter)
			throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		List<Object> countParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder groupbySql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();
		
		groupbySql.append("GROUP BY GROUP_NAME, \n");
		groupbySql.append("  service_code \n");
		
		fromQuery.append("WHERE TRUNC(a.report_date,'DD') >= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery.append("AND TRUNC(a.report_date,'DD')   <= TO_DATE(?,'dd/MM/yyyy') \n");
		fromQuery.append("AND group_id is not null \n");
		selectParams.add(fillter.getFromDate());
		selectParams.add(fillter.getToDate());
		countParams.add(fillter.getFromDate());
		countParams.add(fillter.getToDate());
		
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
			countParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
			countParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
			countParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
			countParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			countParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		
		//DOUBLE 
		for (Object object : selectParams) {
			countParams.add(object);
		}
		
		selectSql.append("SELECT * from( \n");
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  0 newUser, \n");
		selectSql.append("  0 outUser, \n");
		selectSql.append("  0 outUserOther \n");
		selectSql.append("FROM report_user_text_daily a \n");
		selectSql.append(fromQuery);
		selectSql.append(groupbySql);
		selectSql.append("UNION ALL \n");
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  SUM(new_user) newUser, \n");
		selectSql.append("  SUM(out_user) outUser, \n");
		selectSql.append("  SUM(out_user_other) outUserOther \n");
		selectSql.append("FROM report_user_sub_daily a \n");
		selectSql.append(fromQuery);
		selectSql.append(groupbySql);
		selectSql.append(") \n");
		
		selectSql.append("ORDER BY lower(groupName), lower(serviceCode) \n");


		countSql.append("SELECT COUNT(*) AS COUNT FROM( ").append(selectSql).append(")");

		String[] fieldNames = new String[] { 
				"groupName", "serviceCode", "totalUser",
				"newUser", "outUser", "outUserOther" 
				
		};

		Type[] fieldTypes = new Type[] { 
				StandardBasicTypes.STRING, StandardBasicTypes.STRING, StandardBasicTypes.LONG,
				StandardBasicTypes.LONG, StandardBasicTypes.LONG, StandardBasicTypes.LONG
				
		};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), countParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), countParams,
					countParams, fillter.getPaging());
		}
		return list;
	}

	/** (non-Javadoc)
	 * @see com.viettel.core.dao.report.ReportUserDAO#getReportUserAllMonthly(com.viettel.core.entities.report.vo.ReportUserFilter)
	 */
	@Override
	public List<ReportUserVO> getReportUserAllMonthly(ReportUserFilter fillter)
			throws DataAccessException {
		List<Object> selectParams = new ArrayList<Object>();
		List<Object> countParams = new ArrayList<Object>();
		StringBuilder selectSql = new StringBuilder();
		StringBuilder countSql = new StringBuilder();
		StringBuilder groupbySql = new StringBuilder();
		StringBuilder fromQuery = new StringBuilder();
		
		groupbySql.append("GROUP BY GROUP_NAME, \n");
		groupbySql.append("  service_code \n");
		fromQuery.append("AND group_id is not null \n");
		if (fillter.getServiceId() != null
				&& !fillter.getServiceId().equals(0L)) {
			fromQuery.append("AND SERVICE_ID                 = ? \n");
			selectParams.add(fillter.getServiceId());
			countParams.add(fillter.getServiceId());
		}
		if (fillter.getGroupId() != null && !fillter.getGroupId().equals(0L)) {
			fromQuery.append("AND GROUP_ID                 = ? \n");
			selectParams.add(fillter.getGroupId());
			countParams.add(fillter.getGroupId());
		}
		if (fillter.getTelco() != null) {
			fromQuery.append("AND telco                 = ? \n");
			selectParams.add(fillter.getTelco());
			countParams.add(fillter.getTelco());
		}
		if (fillter.getServiceCode() != null) {
			fromQuery.append("AND ( lower(service_code) LIKE (?) ESCAPE '/' \n");
			fromQuery.append("OR lower(service_name) LIKE (?) ESCAPE '/' ) \n");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			selectParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
			countParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() +"%");
			countParams.add("%"+ fillter.getServiceCode().trim().toLowerCase() + "%");
		}
		
		//DOUBLE 
		for (Object object : selectParams) {
			countParams.add(object);
		}
		
		selectSql.append("SELECT * from( \n");
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  0 newUser, \n");
		selectSql.append("  0 outUser, \n");
		selectSql.append("  0 outUserOther \n");
		selectSql.append("FROM report_user_text_monthly a \n");
		selectSql.append("WHERE report_month=TO_NUMBER(TO_CHAR(sysdate,'yyyyMM')) \n");
		selectSql.append(fromQuery);
		selectSql.append(groupbySql);
		selectSql.append("UNION ALL \n");
		selectSql.append("SELECT GROUP_NAME groupName, \n");
		selectSql.append("  service_code serviceCode, \n");
		selectSql.append("  SUM(total_user) totalUser, \n");
		selectSql.append("  SUM(new_user) newUser, \n");
		selectSql.append("  SUM(out_user) outUser, \n");
		selectSql.append("  SUM(out_user_other) outUserOther \n");
		selectSql.append("FROM report_user_sub_monthly a \n");
		selectSql.append("WHERE report_month=TO_NUMBER(TO_CHAR(sysdate,'yyyyMM')) \n");
		selectSql.append(fromQuery);
		selectSql.append(groupbySql);
		selectSql.append(") \n");
		
		selectSql.append("ORDER BY lower(groupName), lower(serviceCode) \n");


		countSql.append("SELECT COUNT(*) AS COUNT FROM( ").append(selectSql).append(")");

		String[] fieldNames = new String[] { 
				"groupName", "serviceCode", "totalUser",
				"newUser", "outUser", "outUserOther" 
				
		};

		Type[] fieldTypes = new Type[] { 
				StandardBasicTypes.STRING, StandardBasicTypes.STRING, StandardBasicTypes.LONG,
				StandardBasicTypes.LONG, StandardBasicTypes.LONG, StandardBasicTypes.LONG
				
		};

		List<ReportUserVO> list = null;
		if (fillter.getPaging() == null) {
			list = repo.getListByQueryAndScalar(ReportUserVO.class,
					fieldNames, fieldTypes, selectSql.toString(), countParams);
		} else {
			list = repo.getListByQueryAndScalarPaginated(
					ReportUserVO.class, fieldNames, fieldTypes,
					selectSql.toString(), countSql.toString(), countParams,
					countParams, fillter.getPaging());
		}
		return list;
	}
}
